<template>
  <mainHead></mainHead>
  <router-view></router-view>
</template>
<script setup>
import { ethers } from "ethers";
import { useRouter } from "vue-router";
import mainHead from "@/components/mainHead.vue"
import { ref, onMounted, onUnmounted, computed, watch } from "vue";
import { showToast } from "vant";
import { useStore } from "vuex";
// import {nowVersion} from "@/utils/config.js"
const store = useStore();
import { useI18n } from "vue-i18n";
import "vant/es/toast/style";
const { locale, t } = useI18n();
const router = useRouter();
const clearData = () => {
 const nowVersion = '20250528change'
  let DBversion = localStorage.getItem('DBversion')
  if (DBversion != nowVersion && nowVersion.includes('change')) {
    let indexDB = window.indexedDB
    indexDB.deleteDatabase('sxbDB')
    localStorage.clear()
  }
  localStorage.setItem('DBversion', nowVersion)
}
watch(
  () => router.currentRoute.value.name,
  (newValue, oldValue) => {
    let chartlist = document.getElementById("app");
    if(oldValue=='index'){
      sessionStorage.setItem('indexTop',chartlist.scrollTop)
    }
    if(newValue=='index'){
      chartlist && (chartlist.scrollTop = Number(sessionStorage.getItem('indexTop')) )
    }
  },
  { immediate: true }
);

clearData()
onMounted(() => {
  let color = localStorage.getItem('themeColor')
  if (color) {
    store.commit('changeThemeColor', color)
  } else {
    color = store.state.themeColor
  }
  document.getElementsByTagName('body')[0].style.setProperty('--theme', color);
})
onUnmounted(() => {
})
// 获取全部商品
</script>

<style lang="scss">
html {
  height: 100vh
}

.van-back-top {
  background-color: $primary-color !important;
  width: 1rem !important;
  height: 1rem !important;

  .van-back-top__icon {
    font-size: 16px;
  }
}

:root {
  --van-count-down-text-color: #fff !important;
  --van-button-loading-icon-size: 12px !important;
  --van-font-size-md: 0.32rem !important;
  --van-cell-line-height: 1 !important;
}
#app {
  // font-family:PingFang SC, Avenir, Helvetica, Arial, sans-serif;
  font-family: BinancePlex, Arial, sans-serif;
  // -webkit-font-smoothing: antialiased;
  // -moz-osx-font-smoothing: grayscale;
  font-size: .32rem;
  font-weight: 400;
  z-index: 2;
  margin: 0 auto;
  max-width: 10rem;
  height: 100%;
  position: relative;
  transform: translateZ(0);
  overflow: auto;
}
.van-popup{
  font-size: .32rem;
}

.van-list__finished-text {
  font-size: .32rem;
}

.padding10 {
  padding: 10px;
}

.orange {
  color: #fea814;
}

.btn_shadow {
  // box-shadow: 4px 4px 12px #dc7f0133, inset -4px -4px 12px #ff8a00,
  //   inset 2px 4px 4px #fffbee33;
}

.van-button--primary {
  border: none;
  background: $primary-color !important;
  font-weight: 400;
  font-size: 12px;
  border-color: $primary-color !important;
}

.van-button {
  width: 100%;
  height: 1.06667rem;
  font-size: 12px;
  font-weight: 500;
  border-radius: 0.53333rem;
}
.fixedD {
  width: 100%;
  // position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  // bottom: calc(env(safe-area-inset-bottom) + 50px);
}
.fixedbutton {
  width: 100%;
  // position: fixed;
  display: flex;
  height: 55px;
  align-items: center;
  justify-content: center;
  // bottom: calc(env(safe-area-inset-bottom));

  .van-button {
    width: 90%;
    height: 36px;
    font-size: 0.32rem;
    font-weight: 500;
    border-radius: 0.53333rem;
  }

  .van-button--primary {
    border: none;
    font-weight: 400;
    color: #fff;
  }
}

.big_btn {
  margin-top: 20px;
  font-size: 12px;
  height: 38px;
  border: none;
  background: $primary-color;
  border-radius: 8px;

  .van-button--primary {
    border: none;
    background: $primary-color;
    font-weight: 400;
    font-size: 12px;
    color: #000;
  }

  .van-button {
    margin-top: 1.06667rem;
    width: 100%;
    height: 1.06667rem;
    font-size: 12px;
    font-weight: 500;
    border-radius: 0.53333rem;
  }
}

.lineheight {
  height: 20px;
}

.copy_class {
  color: #f8ad2c;
  cursor: pointer;
  margin-left: 5px;
}
</style>
<style lang="scss" scoped></style>